<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>巴黎奥运会奖牌榜</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        text-align: center;
        box-sizing: border-box;
      }
      ul,
      li {
        list-style: none;
      }
      .wrap {
        width: 1000px;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        background-color: #000;
        border: 1px solid #cecece;
      }
      .wrap h1 {
        color: aliceblue;
        height: 80px;
        line-height: 80px;
      }
      .wrap li {
        /* padding: 0 200px; */
        background-color: #ccc;
        display: flex;
        justify-content: space-around;
        border-bottom: 1px solid #000;
        line-height: 50px;
      }
      .wrap li:nth-of-type(1) {
        font-size: 20px;
        font-weight: bold;
      }
      .wrap li > span {
        width: 150px;
        height: 50px;
      }
    </style>
  </head>
  <body>
    <div class="wrap">
      <h1>巴黎奥运会奖牌榜</h1>
      <ul>
        <li>
          <span>排名</span><span>国家</span><span>金牌</span><span>银牌</span
          ><span>铜牌</span><span>总计</span>
        </li>
      </ul>
    </div>
  </body>
  <script type="module">
    import axios from "./axios.js";
    function loadList() {
      let url = `https://api.mg-tool.cn/v1/jpb`;
      let HTML = "";
      axios
        .get(url, {
          params: {
            current: "",
          },
        })
        .then(function (response) {
          let arr = response.data.data;
          // console.log(response.data.data);
          arr.forEach((v, index) => {
            HTML += `
                    <li>
                      <span>${index + 1}</span><span>${v.country}</span><span>${
              v.gold
            }</span><span>${v.silver}</span
                      ><span>${v.bronze}</span><span>${v.total}</span>
                    </li>
                    `;
          });
          document.querySelector("ul").innerHTML += HTML;
        });
    }
    loadList();
    console.log("<!-- 小王出品，嘿嘿嘿 -->");
  </script>
</html>
